package domain.entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import utils.CollectionUtils;

public class User implements Serializable {
	private static final long serialVersionUID = -4582033473292577948L;

	private int id;
	private String firstName;
	private String lastName;
	private boolean isDisabled;
	private boolean isDeleted;

	private Organization organization;
	private List<Permission> permissionsList;

	public User() {
		permissionsList = new ArrayList<Permission>();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	public List<Permission> getPermissionsList() {
		return permissionsList;
	}

	public void setPermissionsList(List<Permission> permissionsList) {
		this.permissionsList = permissionsList;
	}

	public boolean hasPermission(Permission permission) {
		return permissionsList.contains(permission);
	}

	public void addPermission(Permission permission) {
		CollectionUtils.addIfNotContains(permissionsList, permission);
	}

	public boolean getIsDisabled() {
		return isDisabled;
	}

	public void setIsDisabled(boolean isDisabled) {
		this.isDisabled = isDisabled;
	}

	public boolean getIsDeleted() {
		return isDeleted;
	}

	public void setIsDeleted(boolean isDeleted) {
		this.isDeleted = isDeleted;
	}
}
